import 'package:flutter/material.dart';

class ScrollViewPage extends StatelessWidget {
  const ScrollViewPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('SingleChildScrollView 示例')),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical, // 滚动方向：横向或竖向
        reverse: false, // 是否反向滚动
        padding: const EdgeInsets.all(16), // 内容内边距
        primary: true, // 是否使用主 ScrollController（通常嵌套时设 false）
        physics: const BouncingScrollPhysics(), // 滚动物理效果
        clipBehavior: Clip.hardEdge, // 裁剪行为
        keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, // 拖动时隐藏键盘
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: List.generate(
            20,
                (index) => Container(
              margin: const EdgeInsets.only(bottom: 12),
              padding: const EdgeInsets.all(16),
              decoration: BoxDecoration(
                color: Colors.blue[100],
                borderRadius: BorderRadius.circular(12),
              ),
              child: Text('内容项 #$index'),
            ),
          ),
        ),
      ),
    );
  }
}
